import Vue from 'vue';
import VueRouter from 'vue-router';
import mainContainer from './components/common/mainContainer.vue';

const _import = file => require(`./${file}.vue`).default;

Vue.use(VueRouter);

// PC端用的路由
const routes = [
    {
        path: '/',
        name: '规则管理',
        component: mainContainer,
        children: [
            {
                name: '规则列表',
                path: 'ruleList',
                component: _import('rule/ruleList'),
            },
            {
                name: '新增规则',
                path: 'ruleConf',
                component: _import('rule/ruleConf'),
            },
            {
                name: '修改规则',
                path: 'ruleConf/:config_id',
                component: _import('rule/ruleConf'),
            },
            {
                name: '模型列表',
                path: 'storageModelList',
                component: _import('model/storageModelList'),
            },
            {
                name: '新增模型',
                path: 'storageModelConf',
                component: _import('model/storageModelConf'),
            },
            {
                name: '修改模型',
                path: 'storageModelConf/:model_id',
                component: _import('model/storageModelConf'),
            },
        ]
    },
    {
        path: '/site',
        name: '站点管理',
        component: mainContainer,
        children: [
            {
                name: '数据源列表',
                path: '/dataSourceList',
                component: _import('site/dataSourceList'),
            },
            {
                name: '新增数据源',
                path: '/dataSourceConf',
                component: _import('site/dataSourceConf'),
            },
            {
                name: '修改数据源',
                path: '/dataSourceConf/:data_source_id',
                component: _import('site/dataSourceConf'),
            },
            {
                name: '抓取站点列表',
                path: '/grabSourceList',
                component: _import('site/grabSourceList'),
            },
            {
                name: '新增抓取站点',
                path: '/grabSourceConf',
                component: _import('site/grabSourceConf'),
            },
            {
                name: '修改抓取站点',
                path: '/grabSourceConf/:station_id',
                component: _import('site/grabSourceConf'),
            }
        ]
    },
    {
        path: '/type',
        name: '分类管理',
        component: mainContainer,
        children: [
            {
                name: '分类列表及配置',
                path: '/categoryList',
                component: _import('type/categoryList'),
            },
            {
                name: '资讯类型列表及配置',
                path: '/infoTypeList',
                component: _import('type/infoTypeList'),
            },
            {
                name: '业务详情列表及配置',
                path: '/businessDetailsList',
                component: _import('type/businessDetailsList'),
            },
        ]
    },
    {
        path: '/tools',
        name: '工具',
        component: mainContainer,
        children: [
            {
                name: '爬虫数据监控配置',
                path: '/monitorConfList',
                component: _import('tools/monitorConfList'),
            },
            {
                name: '队列长度查询',
                path: '/queueQuery',
                component: _import('tools/queueQuery'),
            },
            {
                name: '爬虫测试',
                path: '/crawlTest',
                component: _import('tools/crawlTest'),
            }
        ]
    }
];

export default new VueRouter({
    base: '/crawl',
    mode: 'history',
    routes
});
